package examplePackage;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class for Servlet: Product_detail
 *
 */
 public class Product_detail extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	 private static final long serialVersionUID = 1L;
	public Product_detail() {
		super();
	}   	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		try
		{
			UserBean2 user = new UserBean2();
			user.setPid(request.getParameter("pid"));
			user.setPdescription(request.getParameter("pdescription"));
			user.setVolume(request.getParameter("volume"));
			user.setPrice(request.getParameter("price"));
			user.setPtype(request.getParameter("ptype"));
			user.setQuantity(request.getParameter("quantity"));
		
			user = UserDAO.product_Detail(user);
			if (user.isValid()) 
			{
			HttpSession session = request.getSession(true);
		 	session.setAttribute("currentSessionUser",user);
			response.sendRedirect("profile.jsp");
			}
			else
			{
				response.sendRedirect("profile.jsp");
			}
		}
		catch (Throwable theException) 
		{
			System.out.println(theException);
		}
		// TODO Auto-generated method stub
	}  	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}   	  	    
}